using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;

/// <summary>
/// AKS 1.1 - HiSoftware Inc.
/// CA design: Robert B. Yonaitis 
/// </summary>

namespace AKSAdapters
{
    public class AKS_BlogWiki_Super : System.Web.UI.Adapters.ControlAdapter
    {
        public AKS_BlogWiki_Super()
        {

        }

        protected override void Render(HtmlTextWriter output)
        {
            StringBuilder sb = new StringBuilder();
            HtmlTextWriter writer = new HtmlTextWriter(new StringWriter(sb));
            base.Render(writer);

            sb.Replace("title=\"Select a date from the calendar.\"></IFRAME>", "title=\"Select a date from the calendar.\">The calendar Control requires IFRAME support, please contact your System Administrator</IFRAME>");

            if (Page.Request.Url.ToString().Contains("/EditComment.aspx"))
            {
                sb.Replace("<nobr>Body", "<nobr><label for=\"ctl00_ctl26_g_665a412c_e6f4_4a7d_babe_8326d32bd064_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Body</label>");
                sb.Replace("<nobr>Title", "<label for=\"ctl00_ctl26_g_665a412c_e6f4_4a7d_babe_8326d32bd064_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Title</label>");

            }

            if (Page.Request.Url.ToString().Contains("/EditPost.aspx"))
            {
                sb.Replace("<nobr>Body", "<nobr><label for=\"ctl00_ctl26_g_b79a5391_f006_4a78_9e98_fc35165887ac_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Body</label>");
                sb.Replace("<nobr>Category", "<nobr><label for=\"ctl00_ctl26_g_b79a5391_f006_4a78_9e98_fc35165887ac_ctl00_ctl04_ctl02_ctl00_ctl00_ctl04_ctl00_Lookup\">Category</label>");
                sb.Replace("style=\"display:none\">Published Hours</label>", ">Published Hours</label>");
                sb.Replace("style=\"display:none\">Published Minutes</label>", ">Published Minutes</label>");
                sb.Replace("<nobr>Published", "<nobr><label for=\"ctl00_ctl26_g_b79a5391_f006_4a78_9e98_fc35165887ac_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate\">Published</label>");
                sb.Replace("<nobr>Title", "<nobr><label for=\"ctl00_ctl26_g_b79a5391_f006_4a78_9e98_fc35165887ac_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Title</label>");
            }

            if (Page.Request.Url.ToString().Contains("/NewCategory.aspx"))
            {
                sb.Replace("<nobr>Title", "<nobr><label for=\"ctl00_ctl26_g_1d8e7ea3_2319_43af_bc8e_5732b6f6f7d4_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Title</label>");
            }

            if (Page.Request.Url.ToString().Contains("/Post.aspx"))
            {
                sb.Replace("<nobr>Body", "<nobr><label for=\"ctl00_ctl26_g_87091fdb_c406_4780_b6c6_30401999b99d_ctl00_ctl03_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Body</label>");
                sb.Replace("<nobr>Title", "<nobr><label for=\"ctl00_ctl26_g_87091fdb_c406_4780_b6c6_30401999b99d_ctl00_ctl03_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Title</label>");
            }

            if (Page.Request.Url.ToString().Contains("/NewPost.aspx"))
            {
                sb.Replace("<nobr>Body", "<nobr><label for=\"ctl00_ctl26_g_2952300a_ffd6_4f5a_8e7e_20f32598b29d_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Body</label>");
                sb.Replace("<nobr>Category", "<nobr><label for=\"ctl00_ctl26_g_2952300a_ffd6_4f5a_8e7e_20f32598b29d_ctl00_ctl04_ctl02_ctl00_ctl00_ctl04_ctl00_Lookup\">Category");
                sb.Replace("style=\"display:none\">Published Hours</label>", ">Published Hours</label>");
                sb.Replace("style=\"display:none\">Published Minutes</label>", ">Published Minutes</label>");
                sb.Replace("<nobr>Published", "<nobr><label for=\"ctl00_ctl26_g_2952300a_ffd6_4f5a_8e7e_20f32598b29d_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate\">Published</label>");
                sb.Replace("<nobr>Title<span", "<nobr><label for=\"ctl00_ctl26_g_2952300a_ffd6_4f5a_8e7e_20f32598b29d_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Title</label><span");
            }

            if (Page.Request.Url.ToString().Contains("/NewForm.aspx"))
            {
                sb.Replace("<SPAN CLASS=ms-formdescription>Type the description:", "<SPAN CLASS=ms-formdescription><label for=\"ctl00_ctl26_g_83b7e704_0bbc_42a1_91d9_d3b91e6577cd_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_UrlFieldDescription\">Type the description:</label>");
                sb.Replace("<nobr>Notes", "<nobr><label for=\"ctl00_ctl26_g_83b7e704_0bbc_42a1_91d9_d3b91e6577cd_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Notes</label>");
                sb.Replace("<nobr>URL", "<nobr><label for=\"ctl00_ctl26_g_83b7e704_0bbc_42a1_91d9_d3b91e6577cd_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_UrlFieldUrl\">URL</label>");
            }

            if (Page.Request.Url.ToString().Contains("/EditForm.aspx"))
            {
                sb.Replace("<nobr>Name", "<nobr><label for=\"ctl00_ctl26_g_a555ea71_35b9_4037_a86d_cb3bc9129bd0_ctl00_ctl04_ctl00_onetidIOFile\">Name</label>");
                sb.Replace("<nobr>Wiki Content</nobr>", "<nobr><label for=\"ctl00_ctl26_g_a555ea71_35b9_4037_a86d_cb3bc9129bd0_ctl00_ctl05_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField\">Wiki Content</label></nobr>");
            }
            
            output.Write(sb.ToString());
        }
    }
}



